package com.df.common;

import com.df.handlers.Req_Login_Handler;

import java.util.concurrent.ConcurrentHashMap;

public class MsgHandlerManger {
    //角色管理器
    public ConcurrentHashMap<Integer, IHandler> sessionMap = new ConcurrentHashMap<Integer, IHandler>();

    public void init(){
        sessionMap.put(MsgDefine.Req_Login.msgId, new Req_Login_Handler());
    }



    private MsgHandlerManger(){}

    private enum Singleton{
        SINGLETON;
        MsgHandlerManger instance = new MsgHandlerManger();
        public static MsgHandlerManger getInstance(){
            return SINGLETON.instance;
        }
    }

    public static MsgHandlerManger getInstance(){
        return MsgHandlerManger.Singleton.SINGLETON.instance;
    }


    public IHandler getHandler(int msgId){
        return sessionMap.get(msgId);
    }
}
